package com.itboye.ihomebank.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.bean.WoDeQiuZuBean;
import com.itboye.ihomebank.util.XImageLoader;
/**
 * 我的租房
 */
public class WoDeQiuZuAdapter extends BaseAdapter {
	private Context context;
	
	private ArrayList<WoDeQiuZuBean> list;
	
	public WoDeQiuZuAdapter(Context context,ArrayList<WoDeQiuZuBean>  list) {
		this.context=context;
		this.list=list;
	}

	@Override
	public int getCount() {
		if (list == null) {
			return 0;
		}
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder holder=null;
		if(view==null){
			holder=new ViewHolder();
			view=LayoutInflater.from(context).inflate(R.layout.item_wodeqiuzu, null);
			holder.img_top=(ImageView) view.findViewById(R.id.img_top);
			holder.house_name=(TextView) view.findViewById(R.id.house_name);
			holder.house_tag=(TextView) view.findViewById(R.id.house_tag);
			holder.house_price=(TextView) view.findViewById(R.id.house_price);
			holder.addr=(TextView) view.findViewById(R.id.addr);
			holder.other=(TextView) view.findViewById(R.id.other);
			view.setTag(holder);
		}else{
			holder=(ViewHolder) view.getTag();
		}
		XImageLoader.load(list.get(position).getImgId(), holder.img_top);
		holder.house_name.setText(list.get(position).getTitle());
		holder.addr.setText(list.get(position).getAddressDetail());
		holder.house_price.setText("280万");
		holder.addr.setText(list.get(position).getRent()+"元/平");
		
		
		return view;
	}
	
	class ViewHolder{
		ImageView img_top;//图片
		TextView house_name;//标题
		TextView house_tag;//标签
		TextView house_price;//价格
		TextView addr;//单价
		TextView other;
	}
	

}
